/*
 * Copyright (C) 2012 POAS.VSTU
 */
package ui;

import javax.swing.JPanel;

import model.Card;
import model.CardPile;
import model.CardPileRecycle;

import java.awt.*;
import java.util.List;

/** 
 *
 * @author POAS
 */
public class UICardPileRecycle extends UICardPile {
    
    public UICardPileRecycle(CardPileRecycle pileRecycle, JPanel gamePanel) {
        super(pileRecycle, (UIGamePanel)gamePanel);
    }

    @Override
    public void dragIn(CardPile cards) {
        UICard uiCard;
        for (Card card : cards) {
            uiCard = mPanel.getUICard(card);
            
            if (uiCard.isFaceDown()) uiCard.actionTurnFaceUp(0);
            uiCard.actionSetOrientation(getOrientation(), 0);
            uiCard.actionMoveTo(getLocation(), MovementSpeed.NORMAL, 80);
        }
    }
    
    @Override
    public void push(CardPile cards) {
        int count = mModel.size();
        int dy;
        UICard uiCard;
        
        for (Card card : cards) {
            uiCard = mPanel.getUICard(card);

            dy = 15 * (count - 1);

            uiCard.setZOrder(36 - count);
            uiCard.actionTurnFaceUp(0);
            uiCard.actionMoveTo(new Point(getLocation().x, getLocation().y + dy), MovementSpeed.NORMAL, 0);
        }
    }
}